#ifndef _FSPRINTF_
#define _FSPRINTF_

#include <stdarg.h>

/*********************************************************************
*
*	int2str
*
*	Function description
*		Formatting strings with integer data.
* 
*   Return values
*    	Length of formatted string
*
* 	Example:
* 	int32_t v = -123;
*	//Make sure there is enough room for the formatted characters.
*	char buf[20]; 
* 	
*	int32_t len = int2str(buf, v); -> "-123"
*	printf("len = %d\n", len); -> "len = 4" 
*/
int int2str(char *buf, int v);

/*********************************************************************
*
*	int2str_ex
*
*	Function description
*		Format the shaping data into a string with the specified width, and make up 0 for any shortfall.
*
*   Return values
*    	Length of formatted string
*
* 	Example:
* 	int32_t v = -123;
*	//Make sure there is enough room for the formatted characters
*	char buf[20]; 
* 	
*	int32_t len = int2str(buf, v, 5) -> "-0123"
*	printf("len = %d\n", len); -> "len = 5" 
*/
int int2str_ex(char *buf, int v, int field_width);

//Formatting Unsigned Integers as Strings.Reference int2str.
int uint2str(char *buf, unsigned v);

//Formatting Unsigned Integers as Strings.Reference int2str_ex.
int uint2str_ex(char *buf, unsigned v, int field_width);

//Signed long integers (long long) to strings,return the length of the string.
int lld2str(char *buf, long long v);

//Unsigned long integers (unsigned long long) to strings,return the length of the string.
int llu2str(char *buf, unsigned long long v);

/*********************************************************************
*
*	float2str
*
*	Function description
*		Formats floating-point numbers to a specified precision.
*
* 	Example:
* 	float v = 123.135;
*	//Make sure there is enough room for the formatted characters
*	char buf[20]; 
* 	
*	int32_t len = float2str(buf, v, 1) -> "123.1"
*	printf("len = %d\n", len); -> "len=5"
*
*	int32_t len = float2str(buf, v, 2) -> "123.13"
*	printf("len = %d\n", len); -> "len=6"
*/
int float2str(char *buf, float v, int precision);

/*********************************************************************
*
*  f_sprintf
*
*  Function description
*    Used in the same way as the library function **sprintf**.
*
*  Parameters
*    buf          Buffer for formatted strings.
* 				  
*				  **Warning:** the size of the buf buffer must be large enough to hold the string you need to format, otherwise it will cause a **MEMORY overflow**.
*					
*    s_format     Pointer to format string.
*				  The following formats are supported.
*				  "%c"			- print a character
*				  "%d"	    	- signed 4-byte integer.
*				  "%0nd/%0.nd%" - n indicates the number of zeros required for alignment.
*				  "%u"      	- unsigned 4-byte integer.
*				  "%0nu/%0.nd"  - n indicates the number of zeros required for alignment.
*				  "%f"	    	- 4-byte floating point number.
*				  "%0.nf/%0m.n" - n denotes the width of the fractional part. m denotes the width of the integer part.
*				  "%x/%X"		- hexadecimal.
*				  "%llu"		- unsigned long long, Alignment is not supported for efficiency reasons.
*				  "%lld"		- long long.
*
*    ...   	      parameter list
*
*  Return values
*    Length of formatted string
*/
int f_sprintf(char* buf, const char* s_format, ...);

/*********************************************************************
*
*  f_vsprintf
*
*  Function description
*    Used in the same way as the library function **vsprintf**.
*
*  Parameters
*    buf          Buffer for formatted strings.
* 				  
*				  **Warning:** the size of the buf buffer must be large enough to hold the string you need to format, otherwise it will cause a **MEMORY overflow**.
*					
*    s_format     Pointer to format string.
*				  The following formats are supported.
*				  "%c"			- print a character
*				  "%d"	    	- signed 4-byte integer.
*				  "%0nd/%0.nd%" - n indicates the number of zeros required for alignment.
*				  "%u"      	- unsigned 4-byte integer.
*				  "%0nu/%0.nd"  - n indicates the number of zeros required for alignment.
*				  "%f"	    	- 4-byte floating point number.
*				  "%0.nf/%0m.n" - n denotes the width of the fractional part. m denotes the width of the integer part.
*				  "%x/%X"		- hexadecimal.
*				  "%llu"		- unsigned long long, Alignment is not supported for efficiency reasons.
*				  "%lld"		- long long.
*
*    param_list   Pointer to the list of arguments for the format string.
*
*  Return values
*    Length of formatted string
*/
int f_vsprintf(char* buf, const char* s_format, va_list* param_list);


#endif
